{
    let Instance = null;
    let BULLET_MAP = {
        "1" : "Ryan",
        "2" : "Shark"
    };
    class BulletController {
        constructor () {
            this.bullets = {};

            this.init();
        }

        init () {
            
        }

        addBullets (data) {
            for (let b of data) {
                let bulletClass = Com.Room.Bullet[BULLET_MAP[b.t]];
                if(bulletClass){
                    let bullet = bulletClass.create(b);
                    this.bullets[b.bid] = bullet;

                    Sail.io.publish("role.fire", b);
                    // TODO: b.isSkill
                    // this.roles[b.uid].attack(b.a);
                    Sail.io.publish("map.add", bullet);
                }
            }
            return this;
        }

        removeBullets (data) {
            for (let bid of data) {
                this.bullets[bid].recover();
                delete this.bullets[bid];
            }
            return this;
        }

        reset () {
            for(let i in this.bullets){
                this.bullets[i].recover();
                delete this.bullets[i];
            }
        }

        static get I () {
            if(!Instance){
                Instance = new this;
            }
            return Instance;
        }
    }

    Sail.class(BulletController, "Controller.Bullet");
}